package com.atguigu.dga230301.governance.task;

import com.atguigu.dga230301.governance.bean.GovernanceAssessDetail;
import com.atguigu.dga230301.governance.service.GovernanceAssessDetailService;
import com.atguigu.dga230301.meta.service.TableMetaInfoService;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class AssessScheduleTask {

    @Autowired
    TableMetaInfoService tableMetaInfoService;

    @Autowired
    GovernanceAssessDetailService governanceAssessDetailService;

    @Value("${assess.schemas}")
    String schemaName;


    @Scheduled(cron = "0 25 9 * * *")
    public void assess(){
        //考评日期  正规写法   做测试的话就直接将考评日期写死
//        String assessDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd");

        for (String s : schemaName.split(",")) {

            //元数据
            tableMetaInfoService.initMetaInfo("2023-05-01",s);
        }

        //考评
        governanceAssessDetailService.mainAssess("2023-05-01");
    }
}
